package com.rimi.controller.advise;

import com.rimi.commons.CommonResult;
import com.rimi.commons.ResultStatus;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author luc
 * @Date 2021/7/2
 */
@RestControllerAdvice
public class MyExceptionHanlde  {

    @ExceptionHandler
    public CommonResult exception(AuthorizationException e) {
        //e.printStackTrace();
        return CommonResult.onFailed(ResultStatus.ROLE_AUTH_FAILED);
    }

    @ExceptionHandler
    public CommonResult exception(UnauthorizedException e) {
        //e.printStackTrace();
        return CommonResult.onFailed(ResultStatus.PERMS_AUTH_FAILED);
    }
    @ExceptionHandler
    public CommonResult exception(AuthenticationException e){
        //e.printStackTrace();
        return CommonResult.onFailed(ResultStatus.LOGIN_FAILED);
    }

}
